<template>
  <tbc-dialog title="订单操作记录" ref="dialog">
    <tbc-dynamic-table
        :loading="loading"
        :data="dataList"
        :cols="[
    {label: '时间', prop: 'create_time', width: 200},
    {label: '类型', prop: 'operate_name'},
    {label: '用户', prop: 'nick_name'},
    {label: '管理员', prop: 'admin_nick_name'},
    {label: '说明', prop: 'change_desc'}]">
    </tbc-dynamic-table>
  </tbc-dialog>
</template>
<script lang="ts">
import {defineComponent, ref, Ref} from 'vue'
import http from '@/plugin/http'
import {ElMessage} from 'element-plus'

export default defineComponent({

  name: 'order-operation-list',

  setup() {
    const loading = ref(false)
    const dataList = ref([])
    const dialog: Ref = ref(null)

    const getDataList = async (orderSn: string) => {
      loading.value = true
      const res = await http.get('/order.operation', {
        order_sn: orderSn
      })
      loading.value = false
      if (res.data.code !== 0) return ElMessage.error(res.data.message)
      dataList.value = res.data.data.list as []
    }

    const show = (data: { order_sn: string }): void => {
      dialog.value.show()
      getDataList(data.order_sn)
    }

    return {
      show,
      loading,
      dialog,
      dataList
    }
  }
})
</script>